#include "form2.h"
#include "ui_form2.h"
#include<QTime>
#include"form3.h"
Form2::Form2(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Form2)
{
    ui->setupUi(this);
}

Form2::~Form2()
{
    delete ui;
}
static int b=1,c=1,d=1,e=0,f=0,g=0,h=1,i=0;
static int j,k,l;//事件牌数
static int m,n,o;//骰子数
static int a1,a2,a3;
int num1=0,num2=0,num3=0,num4=0,num5=0,num6=0;
void Form2::on_pushButton_clicked()
{
    if(b==1){
    QTime randtime;
    randtime=QTime::currentTime();
    qsrand(randtime.msec()+randtime.second()*1000);
    a1=qrand()%10;
    a1/=4;
    ui->label_6->setStyleSheet("color:rgb(0, 170, 0)");
    ui->label_6->setText(tr("%1").arg(a1));
    b--;
    e++;
    j=a1;
    num1=j;
    }

}

void Form2::on_pushButton_2_clicked()
{
    if(c==1){
    QTime randtime;
    randtime=QTime::currentTime();
    qsrand(randtime.msec()+randtime.second()*1000);
    a2=qrand()%10;
    a2/=2;
    ui->label_7->setText(tr("%1").arg(a2));
    c--;
    f++;
    k=a2;
    num2=k;
    }

}

void Form2::on_pushButton_3_clicked()
{
    if(d==1){
    QTime randtime;
    randtime=QTime::currentTime();
    qsrand(randtime.msec()+randtime.second()*1000);
    a3=qrand()%10;
    a3/=3;
    ui->label_8->setText(tr("%1").arg(a3));
    d--;
    g++;
    l=a3;
    num3=l;
    }

}
//设置发牌
void Form2::on_pushButton_4_clicked()
{
    if(e==1){
    QTime randtime;
    randtime=QTime::currentTime();
    qsrand(randtime.msec()+randtime.second()*1000);
    a1=qrand()%10;
    a1/=4;
    ui->label_6->setText(tr("%1").arg(a1));
    e--;
    j=a1;
    num1=j;
    }

}

void Form2::on_pushButton_5_clicked()
{
    if(f==1){
    QTime randtime;
    randtime=QTime::currentTime();
    qsrand(randtime.msec()+randtime.second()*1000);
    a2=qrand()%10;
    a2/=2;
    ui->label_7->setText(tr("%1").arg(a2));
    f--;
    k=a2;
    num2=k;
    }

}

void Form2::on_pushButton_6_clicked()
{
    if(g==1){
    QTime randtime;
    randtime=QTime::currentTime();
    qsrand(randtime.msec()+randtime.second()*1000);
    a3=qrand()%10;
    a3/=3;
    ui->label_8->setText(tr("%1").arg(a3));
    g--;
    l=a3;
    num3=l;
    }

}

//设置重新发牌
void Form2::on_pushButton_7_clicked()
{
    if(h==1){
        QTime randtime;
        randtime=QTime::currentTime();
        qsrand(randtime.msec()+randtime.second()*1000);
        int a=qrand()%20;
        ui->label_15->setText(tr("%1").arg(a));
        ui->label_16->setText(tr("%1").arg(20-a));
        int a1=qrand()%10;
        a1/=2;
        ui->label_17->setText(tr("%1").arg(a1));
        h--;
        i++;
        num4=a;
        num5=20-a;
        num6=a1;
    }

}
//设置投色子
void Form2::on_pushButton_8_clicked()
{
    if(i==1){
        QTime randtime;
        randtime=QTime::currentTime();
        qsrand(randtime.msec()+randtime.second()*1000);
        int a=qrand()%20;
        ui->label_15->setText(tr("%1").arg(a));
        ui->label_16->setText(tr("%1").arg(20-a));
        int a1=qrand()%10;
        a1/=2;
        ui->label_17->setText(tr("%1").arg(a1));
        i--;
        num4=a;
        num5=20-a;
        num6=a1;
    }

}
//设置重新投色子
void Form2::on_pushButton_9_clicked()
{
    if(num4==0&&num5==0&&num6==0)
        ;
    else
    {
    this->close();
    Form3 *d=new Form3();
    d->show();
    }
}
//转到第三界面



